home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0011_Lock Keyboard.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  73 lines

  1. {$X+}
  2.  
  3. { Author Trevor J Carlsen.  Released into the public domain. Req TP6   }
  4. { Compile and run this Program and all keyboard input except keys that }
  5. { make up a valid passWord will be ignored.  In this Case the passWord }
  6. { is '1234' and the scancodes For those keys are stored in a Constant. }
  7. { to change the passWord Compute the scancodes For the desired passWord}
  8. { and change the passWord approriately.                                }
  9.  
  10. Uses
  11.   Dos,
  12.   Crt;
  13.  
  14. Var
  15.   OldInt9       : Pointer;   { For storing the old interrupt vector }
  16.   passWord      : String[4];
  17.   pwdlen        : Byte Absolute passWord;
  18.   
  19. Procedure RestoreOldInt9;
  20.   { Restores control to the old interrupt handler }
  21.   begin
  22.     SetIntVec($09,OldInt9);
  23.   end;
  24.  
  25. {$F+}
  26. Procedure NewInt9; interrupt;
  27.  
  28.   Const
  29.     masterpwd :String[4] = #2#3#4#5;  { '1234' scancodes }
  30.   Var 
  31.     scancode  : Byte;
  32.  
  33.   Procedure ResetKBD;
  34.     Var
  35.        b : Byte;
  36.     begin
  37.        b := port[$61]; 
  38.        port[$61] := b or $80;
  39.        port[$61] := b;
  40.        port[$20] := $20; { Signals EOI to PIC }
  41.     end;
  42.   
  43. begin
  44.   scancode    := port[$60]; 
  45.   if chr(scancode)  = masterpwd[pwdlen+1] then begin
  46.     passWord[pwdlen+1]  := chr(scancode);
  47.     inc(pwdlen);
  48.     if passWord = masterpwd then
  49.       RestoreOldInt9;
  50.   end
  51.   else if not odd(scancode shr 7) then { invalid key }
  52.     pwdlen := 0;
  53.   ResetKBD;
  54. end; 
  55. {$F-}
  56.  
  57. begin
  58.   pwdlen := 0;
  59.   GetIntVec($09,OldInt9);
  60.   SetIntVec($09,@NewInt9);
  61.   ReadKey;
  62. end.  
  63.  
  64.      
  65.  
  66.  
  67. TeeCee
  68.  
  69.  
  70. --- TC-ED   v2.01  
  71.  * origin: The Pilbara's Pascal Centre (+61 91 732569) (3:690/644)
  72.  
  73.